<!-- <template>
  <NoIntegrationAlert :loading="noIntegrationsLoading"
                      :total="noIntegrations[`${type}Number`] || 0"
                      :integration="noIntegrations['integrationNumber'] || 0"
                      :type="type"
                      v-if="noIntegrations[`${type}Number`]" />
</template>

<script>
import NoIntegrationAlert from './no-integration-alert'
export default {
  name: 'NoIntegration',
  components: {
    NoIntegrationAlert
  },
  props: {

    type: {
      type: String,
      require: true
    },
    params: {
      type: Object,
      default: () => ({})
    },
    immediate: {
      type: Boolean,
      default: true
    }

  },
  data () {
    return {
      noIntegrationsLoading: false,
      noIntegrations: {}
    }
  },
  created () {
    this.immediate && this.refresh()
  },

  methods: {
    async getNoIntegrations () {
      try {
        this.noIntegrationsLoading = true
        const { get, set } = this._
        const { internal, layoutType, reuse, type, showAllIntegration, businessType, disable, filter = {} } = this.params
        const params = {
          internal, layoutType, reuse, type, showAllIntegration, businessType, disable }
        if (filter.type) {
          set(params, 'filter.type', filter.type)
        }
        const { noIntegrations } = this.$interface.reports

        let { data: response } = await noIntegrations(params, this.type)

        if (response.code !== 0) {
          throw get(response, 'msg', '')
        }

        this.noIntegrations = get(response, 'data', {})
      } catch (error) {

      } finally {
        this.noIntegrationsLoading = false
      }
    },

    refresh () {
      this.getNoIntegrations()
    }
  }
}
</script> -->
